//
//  CityInfo.m
//  HWZB
//
//  Created by 许成雄 on 2017/5/5.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "CityInfo.h"
#import "CountyInfo.h"

@implementation CityInfo

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
             @"cityId" : @"cityid",
             @"city" : @"city",
             @"provinceId" : @"provinceid",
             @"counties" : @"areas"
             };
}

+ (NSValueTransformer *)provinceIdJSONTransformer {
    return [MTLValueTransformer transformerWithBlock:^id(id value) {
        if([value isKindOfClass:[NSNumber class]]) {
            return [value stringValue];
        } else {
            return (NSString *)value;
        }
    }];
}

+ (NSValueTransformer *)countiesJSONTransformer {
    return [MTLValueTransformer reversibleTransformerWithBlock:^id(id value) {
        NSArray *countyArray = [MTLJSONAdapter modelsOfClass:[CountyInfo class] fromJSONArray:value error:nil];
        return countyArray;
    }];
}

@end
